Implement Azure AD OIDC role-based authorization#3
Conversation
| } | ||
|
|
||
| [Authorize(Roles = "User, Admin")] | ||
| [HttpGet("user_and_admin")] |
There was a problem hiding this comment.
use "-" symbol instead of underscore
| IdentityModelEventSource.ShowPII = true; | ||
|
|
||
| app.UseSwagger(); | ||
| app.UseSwaggerUI(); |
There was a problem hiding this comment.
Add Swagger UI config. For example:
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Event Triangle Consumer API V1");
});Don't forget about SwaggerGen configureation. For example:
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1",
new OpenApiInfo { Title = "Event Triangle Consumer API", Version = "v1" });
});|
|
||
|
|
||
| app.UseSwagger(); | ||
| app.UseSwaggerUI(); |
There was a problem hiding this comment.
Add Swagger UI config. For example:
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Event Triangle Sender API V1");
});Don't forget about SwaggerGen configureation. For example:
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1",
new OpenApiInfo { Title = "Event Triangle Sender API", Version = "v1" });
});| [HttpGet(Name = "GetWeatherForecast")] | ||
| public IEnumerable<WeatherForecast> Get() | ||
| [Authorize(Roles = "User, Admin")] | ||
| [HttpGet("user_and_admin")] |
There was a problem hiding this comment.
use "-" symbol instead of underscore
| public IEnumerable<WeatherForecast> Get() | ||
| [Authorize(Roles = "User, Admin")] | ||
| [HttpGet("user_and_admin")] | ||
| public IEnumerable<WeatherForecast> GetForUserAndAdmin() |
There was a problem hiding this comment.
Add to project package Swashbuckle.AspnetCore.Annotations and add [SwaggerOperation] attribute to controler methods
| public IEnumerable<WeatherForecast> Get() | ||
| [Authorize(Roles = "Admin")] | ||
| [HttpGet("admin")] | ||
| public IEnumerable<WeatherForecast> GetForAdmin() |
There was a problem hiding this comment.
Add to project package Swashbuckle.AspnetCore.Annotations and add [SwaggerOperation] attribute to controler methods
|
We need to consider the auth flow as https://security.stackexchange.com/a/130478 |
Closes: #1